package com.zego.wawaji.base.bean;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.zego.wawaji.base.data.BaseData;

import org.json.JSONObject;

/**
 * 公共配置解析类
 * Created by Su on 2017/12/23.
 */
public class Common extends BaseData implements Parcelable {
    private String InviteWwCoinZs;         // 邀请奖励币
    private String HaveRedPacket;           // 公告栏中是否有红包公告 = "1" ： 有
    private String FreeSendWwMin;           // 包邮件数
    private String FreeSendBigWwMin;        // 大娃娃包邮件数
    private String RequsetSendWwCoinMin;    // 邮费价格
    private String InviteImg;               // 邀请页背景
    private String ExchangeImg;             // 商城兑换说明页
    private String ActivityUrl;             // 限时活动页地址
    private String composeRemark;           // 合成娃娃游戏说明
    private String firstRechargeImg;        // 首充界面图片地址
    private String inviteContent;           // 邀请说明内容
    private String inviteWwCoinZsYqNew;     // 被邀请奖币个数
    private String rewardDailyContent;      // 每日礼包内容

    @Override
    public void parseJson(String jsonStr) {
        JSONObject jsonObject = getJsonObject(jsonStr);

        this.InviteWwCoinZs = jsonObject.optString("InviteWwCoinZs");
        this.HaveRedPacket = jsonObject.optString("HaveRedPacket");
        this.FreeSendWwMin = jsonObject.optString("FreeSendWwMin");
        this.InviteImg = jsonObject.optString("InviteImg");
        this.RequsetSendWwCoinMin = jsonObject.optString("RequsetSendWwCoinMin");
        this.ExchangeImg = jsonObject.optString("ExchangeImg");
        this.ActivityUrl = jsonObject.optString("ActivityUrl");
        this.composeRemark = jsonObject.optString("ComposeRemark");
        this.FreeSendBigWwMin = jsonObject.optString("FreeSendBigWwMin ");
        this.firstRechargeImg = jsonObject.optString("FirstRechargeImg");
        this.inviteContent = jsonObject.optString("InviteContent");
        this.inviteWwCoinZsYqNew = jsonObject.optString("InviteWwCoinZsYqNew");
        this.rewardDailyContent = jsonObject.optString("RewardDailyContent");
    }

    public String getRewardDailyContent() {
        return TextUtils.isEmpty(rewardDailyContent) ? "" : rewardDailyContent;
    }

    public String getInviteContent() {
        if (TextUtils.isEmpty(inviteContent)) {
            return "每日转发朋友圈送娃娃币10个" +
                    "\n每日转发微信群送娃娃币10个" +
                    "\n\n好友进入游戏再加送30币" +
                    "\n每天最多可邀请10位好友";
        }

        return inviteContent;
    }

    public String getInviteWwCoinZsYqNew() {
        return inviteWwCoinZsYqNew;
    }

    public String getFirstRechargeImg() {
        return firstRechargeImg;
    }

    public String getFreeSendBigWwMin() {
        return FreeSendBigWwMin;
    }

    public String getComposeTitle() {
        if (TextUtils.isEmpty(composeRemark)) return "玩法介绍";

        JSONObject jsonObject = getJsonObject(composeRemark);
        return jsonObject.optString("Title");
    }

    public String getComposeContent() {
        if (TextUtils.isEmpty(composeRemark))
            return "小主可以任意选择已经" +
                    "抓到的小娃娃或兑换的合成材料进行合成，4个及以上娃娃或材料才可进行合成，点击" +
                    "娃娃图像可更换娃娃，合成" +
                    "几率跟随娃娃大小来决定，" +
                    "几率有大有小，几率不足" +
                    "100%，会出现合成失败现" +
                    "象，小主也可以选择抓娃娃" +
                    "增加娃娃数量进行合成。" +
                    "\n\n大娃娃一件即可包邮哦！";

        JSONObject jsonObject = getJsonObject(composeRemark);
        return jsonObject.optString("Content");
    }

    public String getActivityUrl() {
        return ActivityUrl;
    }

    public String getExchangeImg() {
        return ExchangeImg;
    }

    public String getRequsetSendWwCoinMin() {
        return RequsetSendWwCoinMin;
    }

    public String getInviteImg() {
        return InviteImg;
    }

    public String getFreeSendWwMin() {
        return FreeSendWwMin;
    }

    public boolean haveRedPacket() {
        return TextUtils.equals("1", HaveRedPacket);
    }

    public String getInviteWwCoinZs() {
        return InviteWwCoinZs;
    }

    public Common() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.InviteWwCoinZs);
        dest.writeString(this.HaveRedPacket);
        dest.writeString(this.FreeSendWwMin);
        dest.writeString(this.FreeSendBigWwMin);
        dest.writeString(this.RequsetSendWwCoinMin);
        dest.writeString(this.InviteImg);
        dest.writeString(this.ExchangeImg);
        dest.writeString(this.ActivityUrl);
        dest.writeString(this.composeRemark);
        dest.writeString(this.firstRechargeImg);
        dest.writeString(this.inviteContent);
        dest.writeString(this.inviteWwCoinZsYqNew);
        dest.writeString(this.rewardDailyContent);
    }

    protected Common(Parcel in) {
        this.InviteWwCoinZs = in.readString();
        this.HaveRedPacket = in.readString();
        this.FreeSendWwMin = in.readString();
        this.FreeSendBigWwMin = in.readString();
        this.RequsetSendWwCoinMin = in.readString();
        this.InviteImg = in.readString();
        this.ExchangeImg = in.readString();
        this.ActivityUrl = in.readString();
        this.composeRemark = in.readString();
        this.firstRechargeImg = in.readString();
        this.inviteContent = in.readString();
        this.inviteWwCoinZsYqNew = in.readString();
        this.rewardDailyContent = in.readString();
    }

    public static final Creator<Common> CREATOR = new Creator<Common>() {
        @Override
        public Common createFromParcel(Parcel source) {
            return new Common(source);
        }

        @Override
        public Common[] newArray(int size) {
            return new Common[size];
        }
    };
}
